/*[[
    List Oracle dynamic views(gv$). Usage: @@NAME [keyword]
    Refer to http://www.morganslibrary.org/reference/dyn_perf_view.html

    Sample Output:
    ==============
    ORCL> ora gv rac
        Offline Dictionary:
        ===================
                     NAME              |              V1                            V2                            V3                           V4
        -------------------------------+------------------------------ ----------------------------- ----------------------------- ---------------------------
        Backup and Recovery (RMAN)     |V$BLOCK_CHANGE_TRACKING
        Diagnostics                    |GV$DIAG_APP_TRACE_FILE         GV$DIAG_OPT_TRACE_RECORDS     GV$DIAG_SQL_TRACE_RECORDS     GV$DIAG_TRACE_FILE
        Diagnostics                    |GV$DIAG_TRACE_FILE_CONTENTS    V$DIAG_SESS_OPT_TRACE_RECORDS V$DIAG_SESS_SQL_TRACE_RECORDS
        GoldenGate                     |GV$GOLDENGATE_MESSAGE_TRACKING
        Oracle File System (OFS)       |GV$OFSMOUNT                    GV$OFS_STATS
        Parallel Query                 |GV$PX_PROCESS_TRACE
        Real Application Clusters (RAC)|GV$ACTIVE_INSTANCES            GV$CACHE_TRANSFER             GV$CLUSTER_INTERCONNECTS      GV$CONFIGURED_INTERCONNECTS
        Real Application Clusters (RAC)|GV$CR_BLOCK_SERVER             GV$CURRENT_BLOCK_SERVER       GV$DLM_ALL_LOCKS              GV$DLM_CONVERT_LOCAL
        ...
        Real Application Clusters (RAC)|GV$GLOBAL_TRANSACTION          GV$GWM_RAC_AFFINITY           GV$INSTANCE_CACHE_TRANSFER    GV$INSTANCE_PING
        Real Application Clusters (RAC)|GV$POLICY_HISTORY              GV$TEMP_CACHE_TRANSFER
        Streams                        |GV$STREAMS_MESSAGE_TRACKING
        XStreams                       |GV$XSTREAM_MESSAGE_TRACKING

]]*/

set feed off verify on autohide on
var cur1 REFCURSOR "Offline Dictionary";
var cur2 REFCURSOR "None-existence in Current DB";
var cur3 REFCURSOR "None-existence in Offline Dictionary"

DECLARE
    arg  VARCHAR2(100):=UPPER(:V1);
    TYPE t0 IS TABLE OF VARCHAR2(128);
    TYPE t1 IS TABLE OF t0 INDEX BY VARCHAR2(128);
    t t1;
    c CLOB := '<ROWSET>';
    PROCEDURE PUSH(clz VARCHAR2, lst t0) IS
        ch VARCHAR2(32767);
        n VARCHAR2(300):=clz;
    BEGIN
        n:=replace(n,'"','&quot;');
        n:=replace(n,'&','&amp;');
        t(clz) := lst;
        FOR i IN 1 .. lst.count LOOP
            ch := ch || '<R><N>' || n || '</N><V>'||upper(lst(i))||'</V></R>';
        END LOOP;
        dbms_lob.writeappend(c, length(ch), ch);
    END;
BEGIN
    IF arg IS NOT NULL THEN
        arg := '%'||arg||'%';
    END IF;

    push('Advanced-Queuing',
         t0('gv$aq','gv$aq_partition_stats','gv$aq_dequeue_sessions',
            'gv$aq_server_pool',
            'gv$aq1',
            'gv$aq_sharded_subscriber_stat',
            'gv$aq_background_coordinator',
            'gv$aq_subscriber_load',
            'gv$aq_bmap_nondur_subscribers',
            'gv$aq_uncached_subshards',
            'gv$aq_cached_subshards',
            'gv$buffered_publishers',
            'gv$aq_cross_instance_jobs',
            'gv$buffered_queues',
            'gv$aq_inactive_subshards',
            'gv$buffered_subscribers',
            'gv$aq_job_coordinator',
            'gv$persistent_publishers',
            'gv$aq_message_cache',
            'gv$persistent_qmn_cache',
            'gv$aq_message_cache_advice',
            'gv$persistent_queues',
            'gv$aq_message_cache_stat',
            'gv$persistent_subscribers',
            'gv$aq_msgbm',
            'gv$qmon_coordinator_stats',
            'gv$aq_nondur_registrations',
            'gv$qmon_server_stats',
            'gv$aq_nondur_subscriber',
            'gv$qmon_tasks',
            'gv$aq_nondur_subscriber_lwm',
            'gv$qmon_task_stats',
            'gv$aq_notification_clients',
            'gv$queue',
            'gv$aq_remote_dequeue_affinity',
            'gv$queueing_mth','GV$AQ_IPC_ACTIVE_MSGS','GV$AQ_IPC_MSG_STATS','GV$AQ_IPC_PENDING_MSGS','GV$AQ_REMOTE_DEQUEUE_AFFINITY'));

    push('Analytic Views',t0('gv$av_btt_cache','gv$mdx_cursor_dependency','gv$mdx_cursors'));

    push('Advisors',
         t0('gv$advisor_current_sqlplan',
            'gv$sga_target_advice',
            'gv$advisor_progress',
            'gv$shared_pool_advice',
            'gv$java_pool_advice',
            'v$stats_advisor_actions',
            'gv$memory_target_advice',
            'v$stats_advisor_findings',
            'gv$mttr_target_advice',
            'v$stats_advisor_rationales',
            'gv$pga_target_advice',
            'v$stats_advisor_recs',
            'gv$pga_target_advice_histogram',
            'v$stats_advisor_rules',
            'gv$px_buffer_advice'));
    push('Archive Logging',
         t0('gv$archive',
            'gv$archive_processes',
            'gv$archived_log',
            'gv$proxy_archivedlog',
            'gv$archive_dest',
            'v$proxy_archivelog_details',
            'gv$archive_dest_status',
            'v$proxy_archivelog_summary',
            'gv$archive_gap'));
    push('ASH', t0('gv$active_session_history', 'gv$max_active_sess_target_mth', 'gv$ash_info','gv$all_active_session_history'));
    push('ASM',
         t0('gv$asm_acfsautoresize','gv$asm_acfsrepl',
            'gv$asm_dbclone_info',
            'gv$asm_acfsrepltag','V$ASM_CACHE_EVENTS',
            'gv$asm_disk',
            'gv$asm_acfssnapshots',
            'gv$asm_diskgroup',
            'gv$asm_acfstag',
            'gv$asm_diskgroup_sparse',
            'gv$asm_acfsvolumes',
            'gv$asm_diskgroup_stat',
            'gv$asm_acfs_encryption_info',
            'gv$asm_disk_iostat',
            'gv$asm_acfs_security_info',
            'gv$asm_disk_sparse',
            'gv$asm_acfs_sec_admin',
            'gv$asm_disk_sparse_stat',
            'gv$asm_acfs_sec_cmdrule',
            'gv$asm_disk_stat',
            'gv$asm_acfs_sec_realm',
            'gv$asm_estimate',
            'gv$asm_acfs_sec_realm_filter',
            'gv$asm_file',
            'gv$asm_acfs_sec_realm_group',
            'gv$asm_filegroup',
            'gv$asm_acfs_sec_realm_user',
            'gv$asm_filegroup_file',
            'gv$asm_acfs_sec_rule',
            'gv$asm_filegroup_property',
            'gv$asm_acfs_sec_ruleset',
            'gv$asm_filesystem',
            'gv$asm_acfs_sec_ruleset_rule',
            'gv$asm_operation',
            'gv$asm_alias',
            'gv$asm_quotagroup',
            'gv$asm_attribute',
            'gv$asm_template',
            'gv$asm_audit_cleanup_jobs',
            'gv$asm_user',
            'gv$asm_audit_clean_events',
            'gv$asm_usergroup',
            'gv$asm_audit_config_params',
            'gv$asm_usergroup_member',
            'gv$asm_audit_last_arch_ts',
            'gv$asm_volume',
            'gv$asm_client','GV$ASM_AUDIT_LOAD_JOBS','GV$ASM_DISK_IOSTAT_SPARSE',
            'gv$asm_volume_stat'));

    push('Backup and Recovery (RMAN)',
         t0('gv$backup',
            'gv$db_transportable_platform',
            'v$backup_archivelog_details',
            'gv$deleted_object',
            'v$backup_archivelog_summary',
            'gv$fast_start_servers',
            'gv$backup_async_io',
            'gv$fast_start_transactions',
            'v$backup_controlfile_details',
            'gv$database_block_corruption',
            'v$backup_controlfile_summary',
            'gv$instance_recovery',
            'v$backup_copy_details',
            'v$proxy_copy_details',
            'v$backup_copy_summary',
            'v$proxy_copy_summary',
            'gv$backup_corruption',
            'gv$proxy_datafile',
            'gv$backup_datafile',
            'v$recovery_area_usage',
            'v$backup_datafile_details',
            'v$recovery_file_dest',
            'v$backup_datafile_summary',
            'gv$recovery_file_status',
            'gv$backup_device',
            'gv$recovery_log',
            'v$backup_files',
            'gv$recovery_progress',
            'gv$backup_nonlogged',
            'gv$recovery_slave',
            'gv$backup_piece',
            'gv$recovery_status',
            'v$backup_piece_details',
            'gv$recover_file',
            'gv$backup_redolog',
            'v$restore_range',
            'gv$backup_set',
            'v$rman_backup_job_details',
            'v$backup_set_details',
            'v$rman_backup_subjob_details',
            'v$backup_set_summary',
            'v$rman_backup_type',
            'gv$backup_spfile',
            'gv$rman_compression_algorithm',
            'v$backup_spfile_details',
            'gv$rman_configuration',
            'v$backup_spfile_summary',
            'v$rman_encryption_algorithms',
            'gv$backup_sync_io',
            'gv$rman_output',
            'v$block_change_tracking',
            'gv$tsm_sessions',
            'gv$copy_corruption',
            'v$rman_status',
            'gv$copy_nonlogged',
            'v$sbt_restore_range',
            'gv$database_incarnation',
            'gv$shadow_datafile',
            'gv$datafile_copy',
            'v$unusable_backupfile_details',
            'gv$foreign_datafile_copy'));
    push('Buffers', t0('gv$bh', 'gv$buffer_pool_statistics', 'gv$buffer_pool'));
    push('Caches(bsp = block server background process)',
         t0('gv$bsp',
            'gv$library_cache_memory',
            'gv$cache',
            'gv$map_comp_list',
            'gv$cache_lock',
            'gv$map_element',
            'gv$cache_transfer',
            'gv$map_ext_element',
            'gv$class_cache_transfer',
            'gv$map_file',
            'gv$class_ping',
            'gv$map_file_extent',
            'gv$cr_block_server',
            'gv$map_file_io_stack',
            'gv$current_block_server',
            'gv$map_library',
            'gv$db_cache_advice',
            'gv$map_subelement',
            'gv$db_object_cache',
            'gv$propagation_receiver',
            'gv$gcshvmaster_info',
            'gv$propagation_sender',
            'gv$gcspfmaster_info',
            'gv$gcs_lock_state_resolution_history',
            'gv$rowcache',
            'gv$hvmaster_info',
            'gv$rowcache_parent',
            'gv$instance_cache_transfer',
            'gv$rowcache_subordinate',
            'gv$java_library_cache_memory',
            'gv$subcache',
            'gv$javapool',
            'gv$temp_ping',
            'gv$librarycache'));
    push('Connection Pool', t0('gv$cpool_cc_info', 'gv$cpool_conn_info', 'gv$cpool_cc_stats', 'gv$cpool_stats'));
    push('Container Database',
         t0('gv$clonedfile',
            'gv$con_system_wait_class',
            'gv$containers',
            'gv$con_sys_time_model',
            'gv$con_event_histogram_micro',
            'v$diag_pdb_problem',
            'GV$LOCKDOWN_RULES',
            'gv$con_sysmetric',
            'v$diag_pdb_space_mgmt',
            'gv$con_sysmetric_history',
            'gv$pdbs',
            'gv$con_sysmetric_summary',
            'gv$pdb_incarnation',
            'gv$con_sysstat',
            'gv$proxy_pdb_targets',
            'gv$con_system_event',
            'gv$zonemap_usage_stats',
            'gv$container_topology','gv$con_waitclassmetric','gv$con_waitclassmetric_history'));
    push('Control Files', t0('gv$controlfile', 'gv$controlfile_record_section'));
    push('Cursors and SQL Statements',
         t0('gv$object_dependency','gv$all_sql_monitor','gv$all_sql_plan','gv$all_sql_plan_monitor',
            'gv$sql_monitor_sesstat',
            'gv$open_cursor',
            'gv$sql_monitor_statname',
            'gv$sql',
            'gv$sql_plan',
            'gv$sqlarea',
            'gv$sql_plan_monitor',
            'gv$sqlarea_plan_hash',
            'gv$sql_plan_statistics',
            'gv$sqlstats',
            'gv$sql_plan_statistics_all',
            'gv$sqlstats_plan_hash',
            'gv$sql_redirection',
            'gv$sqltext',
            'gv$sql_diag_repository',
            'gv$sqltext_with_newlines',
            'gv$sql_diag_repository_reason',
            'gv$sql_bind_capture',
            'gv$sql_shared_cursor',
            'gv$sql_bind_data',
            'gv$sql_shared_memory',
            'gv$sql_bind_metadata',
            'gv$sql_workarea',
            'gv$sql_cursor',
            'gv$sql_workarea_active',
            'gv$sql_join_filter',
            'gv$sql_workarea_histogram',
            'gv$sql_monitor',
            'GV$SQL_TESTCASES'));
    push('Data Guard & Standby Databases',
         t0('gv$dataguard_config','GV$DATAGUARD_STATUS',
            'gv$logstdby',
            'gv$dataguard_process',
            'gv$logstdby_process',
            'gv$dataguard_stats',
            'gv$logstdby_progress',
            'v$dataguard_status',
            'gv$logstdby_state',
            'gv$dg_broker_config',
            'gv$logstdby_stats',
            'gv$foreign_archived_log',
            'gv$logstdby_transaction',
            'gv$fs_failover_histogram',
            'gv$managed_standby',
            'gv$fs_failover_observers',
            'gv$rfs_thread',
            'gv$fs_failover_stats',
            'gv$standby_log',
            'gv$fs_observer_histogram','gv$dg_broker_property','gv$dg_broker_property_int',
            'v$standby_event_histogram',
            'GV$NOLOGGING_STANDBY_TXN','V$MY_NOLOGGING_STANDBY_TXN'));
    push('Database Links & Heterogeneous Services', t0('gv$dblink', 'gv$hs_parameter', 'gv$hs_agent', 'gv$hs_session'));

    push('Data Pump', t0('gv$datapump_job', 'gv$datapump_session'));
    push('Diagnostics',
         t0('v$diag_adr_control','gv$diag_user_trace_records',
            'v$diag_sess_sql_trace_records',
            'v$diag_adr_control_aux',
            'gv$diag_sql_trace_records',
            'v$diag_adr_invalidation',
            'v$diag_sweeperr',
            'v$diag_alert_ext',
            'gv$diag_trace_file',
            'v$diag_ams_xaction',
            'gv$diag_trace_file_contents',
            'gv$diag_app_trace_file',
            'v$diag_vem_user_actlog',
            'v$diag_critical_error',
            'v$diag_vem_user_actlog1',
            'v$diag_dde_user_action',
            'v$diag_vhm_run',
            'v$diag_dde_user_action_def',
            'v$diag_view',
            'v$diag_dde_usr_act_param',
            'v$diag_viewcol',
            'v$diag_dde_usr_act_param_def',
            'v$diag_vincident',
            'v$diag_dde_usr_inc_act_map',
            'v$diag_vincident_file',
            'v$diag_dde_usr_inc_type',
            'v$diag_vinc_meter_info',
            'v$diag_vips_file_copy_log',
            'v$diag_dfw_config_capture',
            'v$diag_vips_file_metadata',
            'v$diag_dfw_config_item',
            'v$diag_vips_package_file',
            'v$diag_dfw_patch_capture',
            'v$diag_vips_package_history',
            'v$diag_dfw_patch_item',
            'v$diag_vips_package_main_int',
            'v$diag_dfw_purge',
            'v$diag_vips_package_size',
            'v$diag_dfw_purge_item',
            'v$diag_vips_pkg_file',
            'v$diag_diagv_incident',
            'v$diag_vips_pkg_inc_cand',
            'v$diag_dir_ext',
            'v$diag_vips_pkg_inc_dtl',
            'v$diag_em_diag_job',
            'v$diag_vips_pkg_inc_dtl1',
            'v$diag_em_target_info',
            'v$diag_vips_pkg_main_problem',
            'v$diag_em_user_activity',
            'v$diag_vnot_exist_incident',
            'v$diag_incckey',
            'v$diag_vpdb_problem',
            'v$diag_incident',
            'v$diag_vproblem',
            'v$diag_incident_file',
            'v$diag_vproblem1',
            'v$diag_inc_meter_config',
            'v$diag_vproblem2',
            'v$diag_inc_meter_impt_def',
            'v$diag_vproblem_bucket',
            'v$diag_inc_meter_info',
            'v$diag_vproblem_bucket1',
            'v$diag_inc_meter_pk_impts',
            'v$diag_vproblem_bucket_count',
            'v$diag_inc_meter_summary',
            'v$diag_vproblem_int',
            'gv$diag_info',
            'v$diag_vproblem_lastinc',
            'v$diag_ips_configuration',
            'v$diag_vshowcatview',
            'v$diag_ips_file_copy_log',
            'v$diag_vshowincb',
            'v$diag_ips_file_metadata',
            'v$diag_vshowincb_i',
            'v$diag_ips_package',
            'v$diag_vtest_exists',
            'v$diag_ips_package_file',
            'v$diag_v_actinc',
            'v$diag_ips_package_history',
            'v$diag_v_actprob',
            'v$diag_ips_package_incident',
            'v$diag_v_inccount',
            'v$diag_ips_pkg_unpack_hist',
            'v$diag_v_incfcount',
            'v$diag_ips_progress_log',
            'v$diag_v_inc_meter_info_prob',
            'v$diag_ips_remote_package',
            'v$diag_v_ipsprbcnt',
            'v$diag_log_ext',
            'v$diag_v_ipsprbcnt1',
            'gv$diag_opt_trace_records',
            'v$diag_v_nfcinc',
            'v$diag_pdb_problem',
            'v$diag_v_swperrcount',
            'v$diag_pdb_space_mgmt',
            'gv$incmeter_config',
            'v$diag_pickleerr',
            'gv$incmeter_info',
            'v$diag_problem',
            'gv$incmeter_summary',
            'v$diag_relmd_ext',
            'gv$plsql_debuggable_sessions',
            'v$diag_sess_opt_trace_records',
            'V$DIAG_SESS_USER_TRACE_RECORDS',
            'V$DIAG_VADR_CONTROL'));
    push('Direct Loader', t0('gv$loadistat', 'gv$loadpstat'));
    push('Direct NFS & NFS',
         t0('gv$dnfs_channels', 'gv$nfs_clients', 'gv$dnfs_files', 'gv$nfs_locks', 'gv$dnfs_servers', 'gv$nfs_open_files', 'gv$dnfs_stats'));
    push('Edition Based Redefinition', t0('gv$editionable_types'));
    push('EQ',
        t0( 'gv$eq_cached_partitions',
            'gv$eq_nondur_subscriber_lwm',
            'gv$eq_cross_instance_jobs',
            'gv$eq_partition_stats',
            'gv$eq_dequeue_sessions',
            'gv$eq_remote_dequeue_affinity',
            'gv$eq_inactive_partitions',
            'gv$eq_subscriber_load',
            'gv$eq_message_cache',
            'gv$eq_subscriber_stat',
            'gv$eq_message_cache_advice',
            'gv$eq_subscr_registration_stats',
            'gv$eq_message_cache_stat',
            'gv$eq_uncached_partitions',
            'gv$eq_nondur_subscriber'));
    push('Exadata',
         t0('gv$cell',
            'gv$cell_ioreason',
            'gv$cell_config',
            'gv$cell_ioreason_name',
            'gv$cell_config_info',
            'gv$cell_metric_desc',
            'gv$cell_db',
            'gv$cell_ofl_thread_history',
            'gv$cell_db_history',
            'gv$cell_open_alerts',
            'gv$cell_disk',
            'gv$cell_request_totals',
            'gv$cell_disk_history',
            'gv$cell_state',
            'gv$cell_global',
            'gv$cell_thread_history',
            'gv$cell_global_history'));
    push('Features and Feature Usage', t0('gv$sql_feature', 'gv$sql_feature_hierarchy', 'gv$sql_feature_dependency'));
    push('Fixed Views', 
        t0( 'gv$fixed_table', 
            'gv$transportable_platform', 
            'gv$fixed_view_definition', 
            'gv$version', 
            'gv$build_info',
            'gv$compatibility_requirement',
            'gv$indexed_fixed_column'));
    push('Flashback Database',
         t0('gv$flashback_database_log',
            'v$flashback_txn_mods',
            'gv$flashback_database_logfile',
            'v$recovery_area_usage',
            'gv$flashback_database_stat',
            'gv$restore_point',
            'v$flashback_txn_graph'));
    push('Flashback Recovery Area', t0('v$flash_recovery_area_usage', 'v$recovery_area_usage'));
    push('Flashback Transaction', t0('v$flashback_txn_graph', 'v$flashback_txn_mods'));
    push('GoldenGate',
         t0('gv$gg_apply_coordinator','GV$GOLDENGATE_TABLE_STATS','GV$GOLDENGATE_TRANSACTION',
            'gv$goldengate_capture',
            'gv$gg_apply_reader',
            'gv$goldengate_message_tracking',
            'gv$gg_apply_receiver',
            'gv$goldengate_procedure_stats',
            'gv$gg_apply_server',
            'v$goldengate_table_stats',
            'gv$goldengate_capabilities',
            'v$goldengate_transaction'));
    push('Hang Detection', t0('v$hang_info', 'gv$hang_statistics', 'v$hang_session_info'));
    push('Health Management',
         t0('v$diag_hm_fdg_set',
            'gv$hm_info',
            'v$diag_hm_finding',
            'gv$hm_recommendation',
            'v$diag_hm_info',
            'gv$hm_run',
            'v$diag_hm_message',
            'gv$ir_failure',
            'v$diag_hm_recommendation',
            'gv$ir_failure_set',
            'v$diag_hm_run',
            'gv$ir_manual_checklist',
            'gv$hm_check',
            'gv$ir_repair',
            'gv$hm_check_param',
            'gv$session_fix_control',
            'gv$hm_finding',
            'gv$system_fix_control'));
    push('In-Memory Database',
         t0('gv$imeu_header','GV$IM_GLOBALDICT',
            'gv$im_segments','GV$IM_DELTA_HEADER',
            'gv$im_adoelements','GV$IM_GLOBALDICT_PIECEMAP',
            'gv$im_segments_detail','GV$IM_GLOBALDICT_SORTORDER','GV$IM_GLOBALDICT_VERSION','GV$IM_SMU_DELTA',
            'gv$im_adotaskdetails','GV$INMEMORY_FASTSTART_AREA',
            'gv$im_seg_ext_map','GV$IMHMSEG',
            'gv$im_adotasks',
            'gv$im_smu_chunk',
            'gv$im_column_level',
            'gv$im_smu_head',
            'gv$im_col_cu',
            'gv$im_tbs_ext_map',
            'gv$im_header',
            'gv$im_user_segments',
            'gv$im_imecol_cu',
            'gv$inmemory_area',
            'gv$im_segdict',
            'gv$im_segdict_piecemap',
            'gv$inmemory_xmem_area',
            'gv$im_segdict_sortorder',
            'gv$scheduler_inmem_mdinfo',
            'gv$im_segdict_version',
            'gv$scheduler_inmem_rtinfo'));
    push('I/O',
         t0('gv$file_histogram',
            'gv$file_optimized_histogram',
            'gv$iostat_function',
            'gv$filemetric',
            'gv$iostat_function_detail',
            'gv$filemetric_history',
            'gv$iostat_network',
            'gv$filestat',
            'gv$io_calibration_status',
            'gv$iofuncmetric',
            'gv$io_outlier',
            'gv$iofuncmetric_history',
            'gv$kernel_io_outlier',
            'gv$iostat_consumer_group',
            'gv$lgwrio_outlier',
            'gv$iostat_file',
            'gv$tempstat'));
    push('Instance', t0('gv$active_instances', 'gv$instance_ping', 'gv$instance'));
    push('Keywords', t0('gv$reserved_words'));
    push('Latches & Locks',
         t0('gv$dlm_all_locks',
            'gv$latchholder',
            'gv$dlm_convert_local',
            'gv$latchname',
            'gv$dlm_convert_remote',
            'gv$latch_children',
            'gv$dlm_latch',
            'gv$latch_misses',
            'gv$dlm_locks',
            'gv$latch_parent',
            'gv$dlm_misc',
            'gv$libcache_locks',
            'gv$dlm_ress',
            'gv$lock','GV$_LOCK',
            'gv$dlm_traffic_controller',
            'gv$locked_object',
            'gv$enqueue_lock',
            'gv$locks_with_collisions',
            'gv$enqueue_stat',
            'gv$lock_activity',
            'gv$enqueue_statistics',
            'gv$lock_element',
            'gv$event_name',
            'gv$lock_type',
            'gv$file_ping',
            'gv$mutex_sleep',
            'gv$ges_blocking_enqueue',
            'gv$mutex_sleep_history',
            'gv$ges_deadlocks',
            'gv$process',
            'gv$ges_deadlock_sessions',
            'gv$resource',
            'gv$ges_enqueue',
            'gv$resource_limit',
            'gv$global_blocked_locks',
            'gv$transaction_enqueue',
            'gv$latch',
            'gv_$_lock'));
    push('Log Miner',
         t0('gv$logmnr_contents',
            'gv$logmnr_parameters',
            'gv$logmnr_dictionary',
            'gv$logmnr_process',
            'gv$logmnr_dictionary_load',
            'gv$logmnr_session',
            'gv$logmnr_latch',
            'gv$logmnr_stats',
            'gv$logmnr_logfile',
            'gv$logmnr_transaction',
            'gv$logmnr_logs'));
    push('Materialized View Refresh', t0('gv$mvrefresh','gv$activity_mview','gv$activity_table'));
    push('Diagnostics',
         t0('gv$memory_current_resize_ops',
            'gv$sgastat','GV$MEMOPTIMIZE_WRITE_AREA',
            'gv$memory_dynamic_components',
            'gv$sga_current_resize_ops',
            'gv$memory_resize_ops',
            'gv$sga_dynamic_components',
            'gv$memory_target_advice',
            'gv$sga_dynamic_free_memory',
            'gv$pgastat',
            'gv$sga_resize_ops',
            'gv$process_memory',
            'gv$sga_target_advice',
            'gv$sga',
            'gv$shared_pool_advice',
            'gv$sgainfo',
            'gv$shared_pool_reserved'));
    push('Metrics',
         t0('gv$alert_types',
            'gv$metric_history',
            'gv$eventmetric',
            'gv$sqlpa_metric',
            'gv$event_histogram',
            'gv$sysmetric',
            'gv$metric',
            'gv$sysmetric_history',
            'gv$metricgroup',
            'gv$sysmetric_summary',
            'gv$metricname',
            'GV$SQL_SHARD',
            'gv$threshold_types'));
    push('Miscellaneous',
         t0('gv$auto_bmr_statistics',
            'gv$object_dml_frequencies',
            'gv$bgprocess',
            'v$object_usage',
            'GV$JAVA_PATCHING_STATUS',
            'gv$blocking_quiesce',
            'gv$online_redef',
            'gv$bts_stat',
            'gv$option',
            'gv$bt_scan_cache',
            'gv$patches',
            'gv$bt_scan_obj_temps',
            'gv$ping',
            'gv$calltag',
            'gv$code_clause',
            'gv$quarantine',
            'gv$context',
            'gv$resumable',
            'gv$corrupt_xid_list',
            'gv$scheduler_running_jobs',
            'gv$database',
            'gv$securefile_timer',
            'gv$db_pipes',
            'gv$sqlcommand',
            'gv$dead_cleanup',
            'gv$sqlfn_arg_metadata',
            'gv$detached_session',
            'gv$sqlfn_metadata',
            'v$disk_restore_range',
            'gv$sql_cs_histogram',
            'gv$emon',
            'gv$sql_cs_selectivity',
            'gv$emx_usage_stats',
            'gv$sql_cs_statistics',
            'gv$exp_stats',
            'gv$sscr_sessions',
            'gv$false_ping',
            'gv$subscr_registration_stats',
            'gv$flashfilestat',
            'gv$sysaux_occupants',
            'gv$sys_report_requests',
            'gv$sys_report_stats',
            'gv$timer',
            'gv$timezone_file',
            'gv$heat_map_segment',
            'gv$timezone_names',
            'gv$ios_client',
            'gv$toplevelcall',
            'v_$kccdi',
            'gv$type_size',
            'v_$kccfe',
            'v$unified_audit_record_format',
            'gv$key_vector',
            'gv$unified_audit_trial',
            'v_$kxftask',
            'gv$xs_sessions',
            'gv$license',
            'gv$xs_session_ns_attributes',
            'gv$listener_network',
            'gv$xs_session_roles',
            'gv$mapped_sql',
            'v_x$kswsastab',
            'gv$nonlogged_block',
            'gv$lcr_cache',
            'gv$bcapply_stats',
            'gv$connection_broker',
            'gv$consensus_clients',
            'gv$listener_health',
            'gv$consensus_clients',
            'gv$consensus_logs',
            'gv$consensus_stats',
            'gv$lreg_updstat',
            'gv$pmem_filestore',
            'gv$authpool_stats',
            'gv$securefile_shrink',
            'gv$dual','GV$QUARANTINE_SUMMARY','GV$XS_SESSION_NS_ATTRIBUTE','GV$XS_SESSION_ROLE'));
    push('OLAP', t0('gv$aw_aggregate_op', 'gv$aw_longops', 'gv$aw_allocate_op', 'gv$aw_olap', 'gv$aw_calc', 'gv$aw_session_info'));
    push('Optimizer',
         t0('gv$column_statistics',
            'gv$sql_hint',
            'gv$index_usage_info',
            'gv$sql_optimizer_env',
            'gv$optimizer_processing_rate',
            'gv$sql_reoptimization_hints',
            'gv$rt_addm_control',
            'gv$query_block_origin',
            'gv$sys_optimizer_env',
            'gv$ses_optimizer_env'));
    push('Oracle File System (OFS)', t0('gv$ofsmount', 'gv$ofs_stats'));
    push('Parallel Query',
         t0('gv$execution',
            'gv$px_instance_group',
            'gv$parallel_degree_limit_mth',
            'gv$px_process',
            'gv$pq_sesstat',
            'gv$px_process_sysstat',
            'gv$pq_slave',
            'gv$px_process_trace',
            'gv$pq_sysstat',
            'gv$px_session',
            'gv$pq_tqstat',
            'gv$px_sesstat',
            'gv$px_buffer_advice',
            'gv$qpx_inventory',
            'gv$pq_slaveinfo',
            'V$PQ_GRANDIST',
            'V$PQ_GRANGEN'));
    push('Parameters',
         t0('gv$nls_parameters',
            'gv$spparameter',
            'gv$nls_valid_values',
            'gv$system_parameter',
            'gv$obsolete_parameter',
            'gv$system_parameter2',
            'gv$parameter',
            'gv$system_reset_parameter',
            'gv$parameter2',
            'gv$system_reset_parameter2',
            'gv$parameter_valid_values'));
    push('Processes',
         t0('gv$cleanup_process',
            'gv$process_memory_detail_prog',
            'gv$process_group',
            'gv$process_pool',
            'gv$process_memory_detail',
            'gv$process_priority_data'));
    push('Real Application Clusters (RAC)',
         t0('gv$active_instances',
            'gv$gc_element',
            'gv$cr_block_server',
            'gv$current_block_server',
            'gv$instance_ping', 
            'gv$cache_transfer',
            'gv$cluster_interconnects','GV$GES_TRAFFIC_CONTROLLER',
            'gv$gc_elements_with_collisions','GV$GES_STATISTICS',
            'gv$configured_interconnects','GV$GES_RESOURCE',
            'gv$instance_cache_transfer','GV$GES_LATCH',
            'gv$dynamic_remaster_stats','GV$GES_CONVERT_REMOTE',
            'gv$temp_cache_transfer','GV$GES_CONVERT_LOCAL',
            'gv$file_cache_transfer','GV$GWM_RAC_AFFINITY',
            'gv$dlm_all_locks',
            'gv$dlm_convert_local',
            'gv$dlm_convert_remote',
            'gv$dlm_latch',
            'gv$dlm_locks',
            'gv$dlm_misc',
            'gv$dlm_ress',
            'gv$dlm_traffic_controller',
            'gv$global_transaction',
            'gv$global_blocked_locks',
            'gv$ges_blocking_enqueue',
            'gv$ges_deadlocks',
            'gv$ges_deadlock_sessions',
            'gv$ges_enqueue',
            'gv$gcshvmaster_info',
            'gv$gcspfmaster_info',
            'gv$gcr_actions',            
            'gv$gcr_log',            
            'gv$gcr_metrics',           
            'gv$gcr_status',            
            'gv$policy_history'));
    push('Redo Logs',
         t0('gv$instance_log_group', 'gv$log_history', 'gv$log', 'gv$redo_dest_resp_histogram', 'gv$logfile', 'v$rollname', 'gv$loghist', 'gv$thread'));
    push('Resource Usage',
         t0('gv$access',
            'gv$rsrc_plan_cpu_mth',
            'gv$iostat_consumer_group',
            'gv$rsrc_plan_history',
            'gv$rsrcmgrmetric',
            'gv$rsrc_session_info',
            'gv$rsrcmgrmetric_history',
            'gv$rsrcpdbmetric',
            'gv$rsrc_consumer_group',
            'gv$rsrcpdbmetric_history',
            'gv$rsrc_consumer_group_cpu_mth',
            'gv$rsrc_pdb',
            'gv$rsrc_cons_group_history',
            'gv$rsrc_pdb_history',
            'gv$rsrc_plan'));
    push('Result Cache',
         t0('gv$client_result_cache_stats',
            'gv$result_cache_objects',
            'gv$result_cache_dependency',
            'gv$result_cache_statistics',
            'gv$result_cache_memory',
            'gv$result_subcache_statistics'));
    push('Rollback Segments / Undo Segments', t0('v$rollname', 'gv$undostat', 'gv$rollstat'));
    push('Rules', t0('gv$rule', 'gv$rule_set_aggregate_stats', 'gv$rule_set'));
    push('Security, Privileges, Data Masking/Redaction',
         t0('gv$client_secrets',
            'v$object_privilege',
            'gv$context',
            'gv$passwordfile_info',
            'gv$database_key_info',
            'gv$pwfile_users',
            'gv$enabledprivs',
            'gv$ro_user_account',
            'gv$encrypted_tablespaces',
            'gv$tsdp_supported_feature',
            'gv$encryption_keys',
            'gv$unified_audit_trail',
            'gv$encryption_wallet',
            'gv$vpd_policy',
            'gv$exadirect_acl',
            'gv$wallet',
            'gv$globalcontext',
            'gv$xml_audit_trail',
            'gv$ip_acl',
            'gv$pkcs11_path'));
    push('Services',
         t0('gv$active_services','GV$JAVA_SERVICES',
            'gv$service_event',
            'gv$servicemetric',
            'gv$service_region_metric',
            'gv$servicemetric_history',
            'gv$service_stats',
            'gv$service_wait_class',
            'gv$services'));
    push('Sessions',
         t0('gv$active_session_history',
            'gv$session_cursor_cache',
            'gv$active_sess_pool_mth',
            'gv$session_event',
            'gv$client_stats',
            'gv$session_fix_control',
            'gv$mystat',
            'gv$session_longops',
            'gv$sess_io',
            'gv$session_object_cache',
            'gv$sess_time_model',
            'gv$session_wait',
            'gv$session',
            'gv$session_wait_class',
            'gv$session_blockers',
            'gv$session_wait_history',
            'gv$session_connect_info',
            'gv$sessmetric',
            'gv$sessions_count',
            'gv$sesstat'));
    push('Shared Servers (formerly MTS)',
         t0('gv$circuit',
            'gv$max_active_sess_target_mth',
            'gv$dispatcher',
            'gv$reqdist',
            'gv$dispatcher_config',
            'gv$shared_server',
            'gv$dispatcher_rate',
            'gv$shared_server_monitor',
            'GV$SHARED_SERVER_STAT'));
    push('Storage',
         t0('gv$datafile',
            'gv$nfs_locks',
            'gv$datafile_header',
            'gv$nfs_open_files',
            'gv$dbfile',
            'gv$offline_range',
            'gv$filespace_usage',
            'gv$segspace_usage',
            'gv$chunk_metric',
            'gv$tablespace',
            'gv$lobstat',
            'gv$temporary_lobs',
            'gv$nfs_clients'));
    push('Streams',
         t0('gv$streams_apply_coordinator',
            'gv$streams_message_tracking',
            'gv$streams_apply_reader',
            'gv$streams_pool_advice',
            'gv$streams_apply_server',
            'gv$streams_pool_statistics',
            'gv$streams_capture',
            'gv$streams_transaction'));
    push('System Statistics',
         t0('gv$dml_stats',
            'gv$statistics_level',
            'gv$global_transaction',
            'gv$statname',
            'gv$osstat',
            'gv$sysstat',
            'gv$segment_statistics',
            'gv$system_cursor_cache',
            'gv$segstat',
            'gv$system_event',
            'gv$segstat_name',
            'gv$sys_time_model',
            'gv$serv_mod_act_stats',
            'gv$transaction',
            'gv$sort_usage'));
    push('Temp Space',
         t0('gv$sort_segment',
            'gv$tempfile',
            'gv$tempfile_info_instance',
            'gv$tempseg_usage',
            'gv$temp_extent_map',
            'gv$tempstat',
            'gv$temp_extent_pool',
            'gv$tempundostat',
            'gv$temp_space_header'));
    push('Transportable Platforms', t0('gv$transportable_platform'));
    push('Waits',
         t0('gv$channel_waits',
            'gv$session_wait_history',
            'gv$event_histogram_micro',
            'gv$system_wait_class',
            'gv$event_outliers',
            'gv$waitclassmetric',
            'gv$service_wait_class',
            'gv$waitclassmetric_history',
            'gv$session_blockers',
            'gv$waitstat',
            'gv$session_wait',
            'v$wait_chains',
            'gv$session_wait_class'));
    push('Workload Management', t0('gv$wlm_db_mode', 'gv$wlm_pcmetric_history', 'gv$wlm_pcmetric', 'gv$wlm_pc_stats','GV$WLM_PCSERVICE'));
    push('Workload Replay',
         t0('gv$replay_context','GV$DATABASE_REPLAY_PROGRESS',
            'gv$replay_context_systimestamp',
            'gv$replay_context_lob',
            'gv$wlm_pcmetric',
            'gv$replay_context_sequence',
            'gv$wlm_pcmetric_history',
            'gv$replay_context_sysdate',
            'gv$wlm_pc_stats',
            'gv$replay_context_sysguid',
            'gv$workload_replay_thread'));
    push('XStreams',
         t0('gv$xstream_apply_coordinator',
            'gv$xstream_message_tracking',
            'gv$xstream_apply_reader',
            'gv$xstream_outbound_server',
            'gv$xstream_apply_receiver',
            'gv$xstream_table_stats',
            'gv$xstream_apply_server',
            'gv$xstream_transaction',
            'gv$xstream_capture'));

    dbms_lob.writeappend(c, 9, '</ROWSET>');
    OPEN :cur1 FOR
        with src as(
            SELECT name,v,row_number() over(partition by name order by v) r 
            FROM (
                SELECT EXTRACTVALUE(COLUMN_VALUE,'/R/N') NAME,
                       EXTRACTVALUE(COLUMN_VALUE,'/R/V') V
                FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(c),'/ROWSET/R'))))
            WHERE arg IS NULL OR upper(name) like arg or v like arg)
        SELECT name,
               '' "|",
               max(decode(mod(r-1,4),0,v)) V1,
               max(decode(mod(r-1,4),1,v)) V2,
               max(decode(mod(r-1,4),2,v)) V3,
               max(decode(mod(r-1,4),3,v)) V4
        from   src
        group by name,floor((r-1)/4)
        order by 1,2;

    OPEN :cur2 FOR
       WITH src AS(
            SELECT EXTRACTVALUE(COLUMN_VALUE,'/R/N') NAME,
                   EXTRACTVALUE(COLUMN_VALUE,'/R/V') v
            FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(c),'/ROWSET/R')))),
       diff as(
           select name,v,row_number() over(partition by name order by 1) r
           from   src a, (select * from dba_objects where owner in('SYS','PUBLIC') and object_type in('VIEW','SYNONYM')) b
           where a.v=b.object_name(+)
           and   b.object_name is null
           and   v is not null
           and  (arg IS NULL OR upper(name) like arg or v like arg))
       SELECT name,'' "|",
              max(decode(mod(r-1,4),0,v)) V1,
              max(decode(mod(r-1,4),1,v)) V2,
              max(decode(mod(r-1,4),2,v)) V3,
              max(decode(mod(r-1,4),3,v)) V4
       FROM   diff
       group by name,floor((r-1)/4)
       order by 1,2;

    open :cur3 FOR
       WITH src AS(
            SELECT EXTRACTVALUE(COLUMN_VALUE,'/R/N') NAME,
                   EXTRACTVALUE(COLUMN_VALUE,'/R/V') V
            FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE(c),'/ROWSET/R')))),
       db as ( SELECT MIN(object_name) v
            FROM   DBA_OBJECTS
            WHERE  OBJECT_TYPE IN ('VIEW', 'SYNONYM')
            AND    owner IN ('PUBLIC', 'SYS')
            AND    regexp_like(object_name, '^G?V\$')
               AND   (arg IS NULL OR object_name like arg)
            GROUP  BY regexp_replace(OBJECT_NAME, '^G')),
       diff as (select v,rownum r from (select v from db minus select v from src order by 1))
       SELECT max(decode(mod(r-1,4),0,v)) V1,
              max(decode(mod(r-1,4),1,v)) V2,
              max(decode(mod(r-1,4),2,v)) V3,
              max(decode(mod(r-1,4),3,v)) V4
       FROM   diff
       group by floor((r-1)/4)
       order by 1,2;
END;
/